/**
 * 产品修改js
 */
var comValidform=null;
var returnStatus=false;
var activityAdd={
	activityUE:null,
		
	startEvent:function(){
		$("#recordTab ul").idTabs();
		
		comValidform=$(".com-addForm").Validform({
			datatype:{
				"m0-2" : /^[0-9]+(.[0-9]{1,2})?$/,
				"n1-9" :  /[0-9]{1,2}/
			},
			tiptype:2,
			tipSweep:true,
		
			beforeSubmit:function(curform){
				var url = 'mgr/cardsCtrl/save';
				var params = jsUtils.serializeJson($('.com-addForm'));
				params.creator = userId;
				
				var cb = function(data){
					alert(data.msg);
					//成功返回
					if(data.resultCode==200){
						//关闭窗口并刷新数据
						art.dialog.close();
						returnStatus=true;
					}
				};
				sendApiNoLoadSync(url, params, cb, 'POST');
				return false;
			}
		});
	},
	getResource : function() {
		var url = 'mgr/pointsCtrl/list';
		var params = {
			'curPage' : 0,
			'pageSize' : 9999,
		};
		var cb = function(data) {
			if (data.resultCode == 200) {
				var option = '<option value="">请选择积分规则</option>';
				for (var i = 0; i < data.result.length; i++) {
					var singleObj = data.result[i];
					option = option + '<option value="' + singleObj.id + '">'
							+ singleObj.typeName + '</option>';
				}
				$('select[name="pointsRuleId"]').append(option);
			}
		};
		sendApiNoLoad(url, params, cb, 'POST');

	},
	init:function(){
		activityAdd.getResource();
		activityAdd.startEvent();
	}
}
$(document).ready(function() {
	activityAdd.init();
});
function submitForm(){
	comValidform.submitForm();
	return returnStatus;
}